package com.video.service.impl;

import com.video.dao.VideoMapper;
import com.video.entity.QueryVo;
import com.video.entity.Video;
import com.video.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VideoServiceImpl implements VideoService {


    @Autowired
    private VideoMapper videoMapper;


    @Override
    public List<Video> findAll() {
        return videoMapper.selectByExample(null);
    }

    @Override
    public Video findVideoById(Integer videoId) {

        Video video = videoMapper.findVideoById(videoId);
//        return videoMapper.selectByPrimaryKey(videoId);
        return video;
    }

    @Override
    public List<Video> findByQueryVo(QueryVo queryVo) {
        return videoMapper.findByQueryVo(queryVo);
    }

    @Override
    public Integer getTotalCount() {
        return videoMapper.getTotalCount();
    }

    @Override
    public void insert(Video video) {
        videoMapper.insert(video);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {

        return videoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void updateByPrimaryKey(Integer id) {
        Video video = new Video();
        //videoMapper.updateByPrimaryKey()
    }

    @Override
    public Video findById(Integer id) {
        return videoMapper.selectByPrimaryKey(id);
    }

    @Override
    public void addVideo(Video video) {
        videoMapper.insert(video);
    }

    @Override
    public Integer updateVideo(Video video) {
        return videoMapper.updateByPrimaryKey(video);
    }


}
